﻿<div style="padding: 15px; overflow: hidden">
    <form id="ui_grave_importform" method="post">
        <div title="数据导入" style="padding: 10px">
            <table style="width: 95%">
                <tr>
                    <th>要导入的模板:</th>
                    <td>
                        <a href="/admin/images/数据导入模板.xls" target="_blank">模板下载</a>
                        <input type="hidden" name="ui_grave_import_filename" id="ui_grave_import_filename"  />
                    </td>  
                                      
                </tr> 
                <tr>
                    <th>要导入的文件:</th>
                    <td>
                        <input type="file" name="ui_grave_import_file" id="ui_grave_import_file" onchange="uploadfile()" />
                         <!--a href="javascript:void(0)" class="easyui-linkbutton" onclick="uploadfile()" >上传</a-->
                    </td>                                        
                </tr> 
                <tr>
                    <th>当穴位不存在时自动创建:</th>
                    <td>
                        <input type="checkbox" id="chkAutoCreateGrave" value="1" checked="checked" />
                    </td>                                        
                </tr> 
                <tr>
                    <td colspan="2" > <div id="ui_grave_importform_p" class="easyui-progressbar" data-options="value:0" ></div>      </td>                                       
                </tr>   
                <tr>
                    <td colspan="2" style="text-align:center; color:red;"><div id="ui_grave_importform_msg"></div></td>                                       
                </tr>
                                
            </table>
        </div>
    </form>
    <script>
        function start() {
            var value = $('#ui_grave_importform_p').progressbar('getValue');
            if (value < 95) {
                value += 5;
                $('#ui_grave_importform_p').progressbar('setValue', value);
                setTimeout(arguments.callee, 200);
            }
        };
        function uploadfile() {
            var v = $("#ui_grave_import_file").val();
            //判断是否选择图片  
            if (v == null || v == "") {
                //$.messager.alert('提示', '请选择要导入的文件!');
                $("#ui_grave_import_file").focus();
                return;
            }
            var options = {
                type: "POST",
                url: 'ashx/bg_grave.ashx',
                data:{action:'import',op:'upload'},
                success: function (data) {
                    var res = eval('(' + data + ')');    //转成json格式     
                    $('#ui_grave_importform_p').progressbar('setValue', 100);
                    if (res.success) {                        
                        $('#ui_grave_import_filename').val(res.msg);
                        $('#ui_grave_importform_msg').text("上传成功");
                    } else {
                        $('#ui_grave_import_filename').val("");
                        $('#ui_grave_importform_msg').text(res.msg);
                    }
                }
            };
            // 将options传给ajaxForm  
            start();
            $('#ui_grave_importform').ajaxSubmit(options);
            
        }
    </script>
</div>
